//
//  HHTabController.m
//  Flower
//
//  Created by 花花 on 2016/12/6.
//  Copyright © 2016年 花花. All rights reserved.
//

#import "HHTabController.h"

@interface HHTabController ()<UITableViewDelegate, UITableViewDataSource>
@property(strong, nonatomic)UITableView *tableView;
@property(assign, nonatomic)NSInteger index;

@end

static NSString * const cellId = @"cellID";
@implementation HHTabController

- (void)viewDidLoad {
    [super viewDidLoad];



}

-(void)hh_viewDidLoadForIndex:(NSInteger)index{


    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellId];
    self.data = [NSArray array];
    [self.view addSubview:self.tableView];
}
- (void)hh_viewDidAppearForIndex:(NSInteger)index {
    self.index = index;
    NSLog(@"已经出现   标题: --- %@  index: -- %ld", self.title, (long)index);
    
    if (index%2==0) {
        self.view.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1];
    } else {
        self.view.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1];
        
    }
    // 加载数据
 
    self.data = @[@"新闻头条",@"国际要闻",@"体育",@"中国足球",@"汽车",@"囧途旅游",@"幽默搞笑", @"视频",@"无厘头",@"美女图片",
                  @"今日房价",@"头像",@"家用电器",@"手机/ 运营商/ 数码",@"电脑办公",@"家居",@"家装",@" 厨具",@" 清洁用品",@"鞋靴",
                  @"个护化妆",@"运动",@"汽车用品",@"玩具乐器",@"医药保健",@"家居",@"生鲜",@"食品",@"",@"珠宝",@"酒类",@" 钟表",
                  @"奢侈品",@"特产",@"图书",@"音像",@"电子书",@"",@"票务",@"理财",@"众筹",@"白条",@"保险",@"保险",@"个护化妆"];
    [self.tableView reloadData];
    
}
#pragma mark- UITableViewDelegate, UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.data.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId forIndexPath:indexPath];
    cell.textLabel.text = [NSString stringWithFormat:@"%zd---- %@-----%ld",indexPath.row,self.data[indexPath.row],(long)self.index];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSLog(@"点击了%ld行----", (long)indexPath.row);
    
    
}




@end
